package com.shanjupay.user.service;

import com.shanjupay.user.api.AccountService;
import com.shanjupay.user.api.dto.AccountDTO;
import com.shanjupay.user.convert.AccountCovert;
import com.shanjupay.user.entity.Account;
import com.shanjupay.user.mapper.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;

@org.apache.dubbo.config.annotation.Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountMapper accountMapper;

    @Override
    public AccountDTO createAccount(AccountDTO account) {
        Account entity = AccountCovert.INSTANCE.dto2entity(account);
        accountMapper.insert(entity);
        return AccountCovert.INSTANCE.entity2dto(entity);
    }

    @Override
    public AccountDTO getAccount(Long id) {
        Account entity = accountMapper.selectById(id);
        AccountDTO dto = AccountCovert.INSTANCE.entity2dto(entity);
        return dto;
    }


}
